home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / DATABASE / OBJ1_2.ZIP;1 / C_BROWSE.TXT < prev    next >
Encoding:
Text File  |  1992-12-22  |  13.0 KB  |  312 lines

  1. '
  2. 'Class desription:
  3. '
  4. !short:Browse class structure:
  5. Class  Browse:
  6. ~~~~~~~~~~~~~~
  7. It serves as key-precessing by view/edit of structured data
  8. (arrays or database files) with help of standard clipper class TBrowse.
  9. Two ways of displaying of data table are introduced:
  10.   1.Browse = classical form of displaying.
  11.   2.Form = only one table row is displayed, with all data put one under other.
  12.  
  13. Common use:
  14. ~~~~~~~~~~~~
  15. LOCAL OBJECT Br OF Browse
  16. Br:Init(...)       //or Br:GoodInit(...)    
  17. Br:AddBlock(...)   //could be repeated or could be Br:AddGet(...)
  18. ...
  19.  
  20. Methods AddBlock() and AddGet() could be mixed and repeated, or instvar
  21. variables of this object can be changed (i.g.Br:CanSwap:=false).
  22. You don't take care for displaying, editation because the parent class Task
  23. methods do the work for us.
  24.  
  25. If you need to produce the displayer of structured data, and you can't use
  26. the classes ABrowse or DBrowse, you can as superset of this class write 
  27. your own displayer.
  28.  
  29. Source code of class Browse is in C_Browse.prg
  30.  
  31. !seealso: c_task.ngo:Task c_window.ngo:Window c_box.ngo:Box c_abrows.ngo:ABrowse c_dbrows.ngo:DBrowse c_color.ngo:Color ob_class.ngo:"Class hierarchy"
  32.  
  33. !short:~~~~~~~~~~~~~~~~~~~~~~~~
  34. !short:create class Browse from Task
  35. !short:  export:
  36. !short:  var MoreRecords      //true
  37. ^BBrowse:MoreRecords^N: private: logical
  38.   Internal variable for Browse and View used for correct displaying of help
  39.   text obtained by F1 key.
  40.  
  41. !short:  var MaskFeature      //false
  42. ^BBrowse:MaskFeature^N: public:logical
  43.   Abstract variable used for indication of creation of the object from
  44.   the class Mask (or its descendats).
  45.  
  46. !short:  var CanShowSkip      //false
  47. ^BBrowse:CanShowSkip^N: public: logical
  48.   If true, after each skip command is in the dialog line displayed information
  49.   about searching for next record (usefull with filter switched on for long
  50.   search for next record)
  51.  
  52. !short:  var CanEdit          //true
  53. ^BBrowse:CanEdit^N: public: logical
  54.   Enables - disables editation of data displayed with this object.
  55.  
  56. !short:  var CanAppend        //true
  57. ^BBrowse:CanAppend^N: public: logical
  58.   Enables - disables appending or deleting of a line of displayed table. If
  59.   CanEdit is false no change of the table is allowed and instvar variable
  60.   CanAppend  has no sense.
  61.  
  62. !short:  var CanSwap          //true
  63. ^BBrowse:CanSwap^N: public: logical
  64.   Enables / disables  Browse - Form switching.
  65.  
  66. !short:  var CanSkip          //true
  67. ^BBrowse:CanSkip^N: public: logical
  68.   Only in Form display, enables - disables next or previous table line
  69.   skipping with PgDn/PgUp key.
  70.  
  71. !short:  var FormActive       //false
  72. ^BBrowse:FormActive^N: public: logical
  73.   If display is switched to Form the instvar variable is true. The display
  74.   mode (Form/Browse) of the object can be initialised by assigning of logical
  75.   value to this variable.
  76.  
  77. !short:  var CanMoveCursor    //true
  78. ^BBrowse:CanMoveCursor^N: public: logical
  79.   If true, the finishing of editation moves cursor in the direction in which
  80.   we entered the edited field. Otherwise is cursor moved to right.
  81.   (if is it possible)
  82.  
  83. !short:  var Direction        //K_RIGHT
  84. ^BBrowse:Direction^N: public: numeric
  85.   Variable for saving the last cursor key pressed before entering edited
  86.   field. After leaving this field cursor is moved to direction after this 
  87.   variable.
  88.  
  89. !short:  var QuickEdit        //true
  90. ^BBrowse:QuickEdit^N: public: logical
  91.   When starting the editation in Browse mode is this variable true, direct
  92.   entering the field is enabled, if false the editation of the field is
  93.   possible after pressing the Enter key.
  94.  
  95. !short:  var SetConfirm       //Set(_SET_CONFIRM)
  96. ^BBrowse:SetConfirm^N: public: logical
  97.   Saves local value of clipper switch SET CONFIRM... for this object.
  98.   Diferent objects can have diferent values of this switch.
  99.  
  100. !short:  var AddMsg           //""
  101. ^BBrowse:AddMsg^N: public: character
  102.   Text string which is appended to dialog line when this window is active.
  103.  
  104. !short:  var InsBlock         //{|o|nil}
  105. ^BBrowse:InsBlock^N: public: code_block
  106.   Code block (as parameter by activation recieves self object), serving for
  107.   adding next line to table edited by this object.If CanAppen is false, this
  108.   code block is not activated, otherwise it is activated by pressing the Ins
  109.   key in Browse mode. Form mode has no possibility for appending or deleting
  110.   of the line from edited table.
  111.  
  112. !short:  var DelBlock         //{|o|nil}
  113. ^BBrowse:DelBlock^N: public: code_block
  114.   The same as InsBlock, but serves for deleting the line from the table,
  115.   activated by pressing the Del key.
  116.  
  117. !short:  var PreSkip          //nil
  118. public: code_block
  119.   If not nil, is processed for each skip.
  120.  
  121. !short:  var PostSkip         //nil
  122. public: code_block
  123.   If not nil, is precessed after each skip.
  124.  
  125. !short:  var InfoBlock        //{|o|nil}
  126. ^BBrowse:InfoBlock^N: public: code_block
  127.   This code block is processed when object is waiting for key pressing.
  128.   As a parameter recieves self object.
  129.  
  130. !short:  var TestVRecord      //{|o,g|true}
  131. ^BTestVRecord(Brovse,Get)^N:public: code_block: return true
  132.   Tests if variable which is manipulated by the Get object is not a virtual
  133.   record in database file. (i.e.RecNo()<=LastRec()). It has no sense to edit
  134.   virtual record due to lose of any changes after finishing of such editation.
  135.  
  136. !short:  var GetList          //{}
  137. ^BBrowse:GetList^N: private: array
  138.   Array of clippper get objects for editation of table fields. Each field
  139.   has its own get object.
  140.  
  141. !short:  var DoGetList        //{}
  142. ^BBrowse:DoGetList^N: private: array
  143.   Array of code blocks, which with get objects from Getlist array serve for
  144.   edit of table fields. Each field ha sits own (indenpendent) code block.
  145.  
  146. !short:  var DelGet           //{}
  147. ^BBrowse:DelGet^N: private: array
  148.   User can exclude not interesting fields from the view. These are transferred
  149.   from instvar variable Getlist to instvar variable (array) DelGet. In the same
  150.   time are code blocks transferred from DoGetlist to DelDoGet.
  151.  
  152. !short:  var DelDoGet         //{}
  153. ^BBrowse:DelDoGet^N: private: array
  154.   As DelGet, serves for saving of code blocks of instvar variable DoGetList,
  155.   when user excludes some fields from the view of the table.
  156.  
  157. !short:  var Tb               //nil
  158. ^BBrowse:Tb^N: public: clipper_object
  159.   This Clipper object manipulates with edited or viewed table.
  160.   Must be used as instvar, because the Oclip-library don't allow to inherit
  161.   from the original clipper classes.
  162.  
  163. !short:  var Freeze           //0
  164. ^BBrowse:Freeze^N: public: numeric
  165.   Contains number of fields of the table which must be locked on left side
  166.   of the window. The lock is valid for Form mode too, but there it appears
  167.   as locking of form rows from the upper side of the window.
  168.  
  169. !short:  var FormTop          //1
  170. ^BBrowse:FormTop^N: public: numeric
  171.   Contains field number in Form mode which should be displayed as first line
  172.   in Form window.
  173.  
  174. !short:  var Form             //(object of Window)
  175. ^BBrowse:Form^N: private: object_of_window
  176.   Serves as Form mode window.
  177.  
  178. !short:  var SetUp            //false
  179. ^BBrowse:SetUp^N: private: logical
  180.   Before first processing of method Process() of this class is necessary
  181.   to finish the initialisation of clipper object TBrowse, if it is done the
  182.   instvar variable Setup is true. It is because the clipper class TBrowse
  183.   has no Copy() method for returning of identical copy of self object.
  184.  
  185. !short:  method New=BrowseNew           //o:New() --> self
  186. ^BBrowse:New()^N: public: return self
  187.   Fills object with default initialising values.
  188.  
  189. !short:  method Init=BrowseInit         //o:Init(Name,R,C,Rs,Cs,Clr,Shd) --> true
  190. ^BBrowse:Init(Name,R,C,Rs,Cs,Clr,Shadow)^N: public: return true
  191.   Object is initialised, when method is finished the Tb object (of TBrowse
  192.   class) is still empty. The parameters are passed till to the class Box 
  193.   method Init(). For detailed description see the class Box.
  194.  
  195. !short:  method GoodInit=BrowseGoodInit //o:GoodInit(Name,R,C,Rs,Cs,CurSize,Clr,Shd) --> true
  196. ^BBrowse:GoodInit(Name,R,C,Rs,Cs,CurSize,Clr,Shadow)^N: public: return true
  197.   It is the same as Browse:Init(..) but by placing of the window on the
  198.   screen is used the principe ^UGoodInit^N defined in parent class Box.
  199.   The parameters are the same as in the class Box.
  200.  
  201. !short:  method AddBlock=BrowseAddBlock //o:AddBlock(LongNm,ShortNm,VarNm,Block,DoGet,Pict,When,Valid) --> true
  202. ^BBrowse:AddBlock(LongName,ShortName,VarName,Block,DoGet,Picture,When,Valid)^N:
  203.   public: return true
  204.   Next column of the table is appended to this object.
  205.   During the editation is the record virtuality not tested i.e. database
  206.   record can be edited even if RecNo()>LastRec().
  207.  
  208.   Parameter description
  209.   ~~~~~~~~~~~~~~~~~~~~~
  210.   ^ULongName^N: character: default is ShortName
  211.    It is name of column used in Form mode.
  212.  
  213.   ^UShortName^N: character: default is ""
  214.    It is name of column used in Browse mode.
  215.  
  216.   ^UVarName^N: character: default is ShortName
  217.    It is name of edited variable, or the name of database field and will
  218.    be saved as information to clipper Get objet created in this method
  219.    and saved to array DoGet. It is because clipper get object used for
  220.    editation should know the name of the edited variable.
  221.  
  222.   ^UBlock^N: code_block: no default
  223.    It is code block of get/set type, you can create by clipper functions
  224.    FieldBlock(), FieldWBlock(), MemVarBlock() or by own piece of program.
  225.  
  226.   ^UDoGet^N: code_block: default is virtual_method_Browse:DoGet()
  227.    It is code block which with help of Get object edits a variable
  228.    (database field) in current table column.
  229.  
  230.   ^UPicture^N: character: default is ""
  231.    It is display mask for display mode of current column.
  232.  
  233.   ^UWhen^N: code_block: default is {||true}
  234.    It is code block, evaluated before entering the editation of current column,
  235.    if it is false the editation is skipped. Could be used for computed fields
  236.    of table or read-only columns.
  237.  
  238.   ^UValid^N: code_block: default is {||true}
  239.    It is code block, evaluated after finishing of editation of current
  240.    column. His job is to evaluate if the new entered value is valid, 
  241.    in this case returns true, otherwise false.
  242.  
  243. !short:  method AddGet=BrowseAddGet     //o:AddGet(Get,DoGet) --> true
  244. ^BBrowse:AddGet(Get,DoGet)^N: public: return true
  245.   Adds new column to this object.
  246.  
  247.   Parameter description:
  248.   ~~~~~~~~~~~~~~~~~~~~~~
  249.   ^UGet^N: clipper_Get_objekt: no  default
  250.    Is used for variable input and the also for saving of new value
  251.    to variable which refers to table column (of course to table row). 
  252.    Pay attention to Cargo variable of this object (Get:Cargo) which should
  253.    content a array with following data:
  254.      1. cLongName  = name used in Form mode
  255.      2. cShortName = name used in Browse mode
  256.      3. cAlias     = Alias database name if it is a database field (or "")
  257.      4. zero (0)   = internal (for saving Col() cursor coordinate)
  258.    Example: Get:Cargo:={"Employee name","Name","DbfEmp",0}
  259.  
  260.   ^UDoGet^N: code_block: default is virtual_method_Browse:DoGet()
  261.    It is code block which with help of Get object edits a variable
  262.    (database field) in current table column.
  263.  
  264. !short:  method PostInit=BrowsePostInit //o:PostInit() --> true
  265. ^BBrowse:PostInit()^N: private: return true
  266.   It is used for calculating of actual window size in Form mode.
  267.  
  268. !short:  method DoGet=BrowseDoGet       //o:DoGet() --> true
  269. ^BBrowse:DoGet()^N: private: return true
  270.   It is used for one field editation in Browse mode. The Form mode
  271.   is written as indenpendent static function BrowseDoForm()
  272.   for speed reasons.
  273.  
  274. !short:  method VPaint=BrowseVPaint     //o:VPaint() --> true
  275. ^BBrowse:VPaint()^N: private: return true
  276.   Paints window content with use of RefreshAll() method to clipper object Tb
  277.   of TBrowse class. Tb object is the instvar variable of Tb object of Browse
  278.   class.
  279.  
  280. !short:  method SwapForm=BrowseSwapForm //o:SwapForm() --> true
  281. ^BBrowse:SwapForm()^N: public: return true
  282.   Browse - Form mode switching.
  283.  
  284. !short:  method VProcess=BrowseVProcess //o:VProcess() --> true
  285. ^BBrowse:VProcess()^N: private: return true
  286.   The table editation.
  287.  
  288. !short:  method Process=BrowseProcess   //o:Process() --> true
  289. ^BBrowse:Process()^N: public: return true
  290.   The parrent method (Task) is changed for use of PostInit() method
  291.   in the Browse class.
  292.  
  293. !short:  method DoForm=BrowseDoForm     //o:DoForm() --> true
  294. ^BBrowse:DoForm()^N: private: return true
  295.   It is VProcess() (i.e. key-processing) for Form mode.
  296.  
  297. !short:  method DoBrowse=BrowseDoBrowse //o:DoBrowse() --> true
  298. ^BBrowse:DoBrowse()^N: private: return true
  299.   It is VProcess() (i.e. key-processing) for Browse mode.
  300.  
  301. !short:  method FormPaint=BrowseFormPaint  //o:FormPaint() --> true
  302. ^BBrowse:FormPaint()^N: public: return true
  303.   It is VirtualPaint method (doing the job in current window) for Form mode
  304.   (::FormActive==true) of Browse class object.
  305.  
  306. !short:  method MaskPaint=BrowseMaskPaint  //o:MaskPaint() --> true
  307. ^BBrowse:MaskPaint()^N: public: return true
  308.   Abstract method used for class Mask objects (redefined in class Mask).
  309.  
  310. !short:  endclass
  311.  
  312.